//
//  XQBaseIndentityChoosePopCell.swift
//  Spark Peso
//
//  Created by 小琦 on 2025/2/10.
//

import UIKit

class XQBaseIndentityChoosePopCell: UITableViewCell {

    var onTapHandle: (() -> Void)?
    
    var content : String = "" {
        didSet {
            self.contentLb.text = content
        }
    }
    
    var textAligment : NSTextAlignment? {
        didSet {
            self.contentLb.textAlignment = textAligment!
        }
    }
    
    private lazy var button : UIButton = {
        let btn = UIButton()
        btn.addTarget(self, action: #selector(buttonClick), for: .touchUpInside)
        return btn
    }()

    func position(middle : Bool,middleOne : Bool, middleTwo : Bool) {
        self.contentLb.font = UIFont.systemFont(ofSize: middle ? 16 : 15, weight: .medium)
        if (middle) {
            self.contentLb.textColor = .white
        }else {
            if (middleOne) {
                self.contentLb.textColor = .xq_black
            }else {
                self.contentLb.textColor = .xq_black.withAlphaComponent(0.5)
            }
        }
    }
    
    private lazy var contentLb : UILabel = {
        let lb = UILabel()
        lb.textAlignment = .left
        lb.adjustsFontSizeToFitWidth = true
        return lb
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
       super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.backgroundColor = .clear
        self.contentView.backgroundColor = .clear
        makeUI()
        makeConstraints()
    }

    required init?(coder: NSCoder) {
       fatalError("init(coder:) has not been implemented")
    }
    
    private func makeUI() {
        self.contentView.addSubview(self.contentLb)
        self.contentView.addSubview(self.button)
    }
    
    private func makeConstraints() {
        self.contentLb.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        self.button.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
    
    @objc private func buttonClick() {
        onTapHandle?()
    }

}
